/**
 * Copyright (c) 2005 - 2007 FeyaSoft Corp. All Rights Reserved.
 */
package com.feyaSoft.home.hibernate.feedback;

import java.io.Serializable;
import java.util.Date;

import org.json.JSONObject;

import com.feyaSoft.plugin.util.DateUtil;

/**
 * @author Fenqiang Zhuang
 * @Oct 10, 2007
 *
 * This file is used to create feedback POJO
 */
public class Feedback implements Serializable {
	private static final long serialVersionUID = -6607672285365469294L;

	private Long id;
	private String subject = null;
	private String author = null;
	private String description = "";
	private String status = "active";
	private Long parentId = new Long(0);
	private int comments = 0;
	private String email = null;
	private Date creationDate = new Date();
	private Date updateDate = new Date();
	
	public String getAuthor() {
		return author;
	}
	public void setAuthor(String author) {
		this.author = author;
	}
	public Date getCreationDate() {
		return creationDate;
	}
	public void setCreationDate(Date creationDate) {
		this.creationDate = creationDate;
	}
	public String getDescription() {
		return description;
	}
	public void setDescription(String description) {
		this.description = description;
	}
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	public Long getParentId() {
		return parentId;
	}
	public void setParentId(Long parentId) {
		this.parentId = parentId;
	}
	public String getStatus() {
		return status;
	}
	public void setStatus(String status) {
		this.status = status;
	}
	public String getSubject() {
		return subject;
	}
	public void setSubject(String subject) {
		this.subject = subject;
	}
	public Date getUpdateDate() {
		return updateDate;
	}
	public void setUpdateDate(Date updateDate) {
		this.updateDate = updateDate;
	}
	public int getComments() {
		return comments;
	}
	public void setComments(int comments) {
		this.comments = comments;
	}
	public String getEmail() {
		return email;
	}
	public void setEmail(String email) {
		this.email = email;
	}
	/**
	 * This is for JSON - ajax part...
	 * 
	 * @return
	 * @throws Exception
	 */
	public JSONObject toJSONObject() throws Exception {		
		String updateDateString = DateUtil.format(updateDate, "MMM dd, yyyy hh:mm aaa");
		String createDateString = DateUtil.format(creationDate, "MMM dd, yyyy hh:mm aaa");

		JSONObject json = new JSONObject();
		json.put("updateDate", updateDateString);
		json.put("creationDate", createDateString);
		json.put("subject", this.subject);
		json.put("author", this.author);
		json.put("description", this.description);
		json.put("status", this.status);
		json.put("comments", this.comments);
		json.put("email", "");
		json.put("parentId", this.parentId);
		json.put("id", this.id);

		return json;
	}
}
